﻿
Public Class frmNumPad
    Public IsNumber As Boolean = True

    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
       Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click
        Dim btn As System.Windows.Forms.Button
        btn = sender
        If IsNumber Then
            txtResult.Text = String.Format("{0:n0}", CDbl(txtResult.Text + btn.Name.Substring(btn.Name.Length - 1, 1)))
        Else
            txtResult.Text = txtResult.Text + btn.Name.Substring(btn.Name.Length - 1, 1)
        End If

    End Sub
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtResult.Text = "0"
    End Sub
    Private Sub btn00_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn00.Click
        txtResult.Text = String.Format("{0:n0}", CDbl(txtResult.Text + "00"))
    End Sub
    Public Property Value() As String
        Get
            Value = txtResult.Text
        End Get
        Set(ByVal value As String)
            txtResult.Text = value
        End Set
    End Property
    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        If txtResult.Text = "" Then Return
        txtResult.Text = txtResult.Text.Remove(txtResult.Text.Length - 1, 1)
    End Sub


End Class